/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.io.BufferedWriter;

/**
 *
 * @author jhon
 */
public class FileWriter {

    private String filename;

    public FileWriter(String file) {

        filename = file;
    }

    public void writeToFile(int maxConn, int minConn, int threads, int repeats, double totalTime) {
        try {
            java.io.FileWriter fstream = new java.io.FileWriter(filename, true);
            BufferedWriter out = new BufferedWriter(fstream);
            out.append(maxConn + "," + minConn + "," + threads + "," + repeats + "," + totalTime);
            out.newLine();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void clearFile() {
        try {
            java.io.FileWriter fstream = new java.io.FileWriter(filename, false);
            BufferedWriter out = new BufferedWriter(fstream);
            out.append("Max. Connections" + "," + "Min. Connections" + "," + "Threads" + "," + "Repeats" + "," + "Total Time by all operations");
            out.newLine();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
